/*
 * Copyright 2012-2022 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 * https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations under the License.
 */
package org.wisdom.data.jpa.annotation;

import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * 编号自动生成 编号由数字序号和字符串组成 数字序号自增长
 *
 * @author 张智研
 * @date 2022/05/18 10:48
 */
@Retention(RetentionPolicy.RUNTIME)
@Target(value = {FIELD, METHOD})
public @interface SerialNumber {

    /**
     * 编号生成器key，同一key下数字序号自增长并且唯一 {t}代表实体名 {d}代表时间 {xxx}xxx代表实体内属性 默认格式为{t}-{d}
     * 例如：org.wisdom.data.jpa.entity.Demo-20220518
     */
    String key() default "{t}{d}";

    /**
     * 编码格式 {d}代表时间 {n}代表指定长度数字字符串，前补"0" {m}代表不指定长度数字序号 {xxx}xxx代表实体内属性 默认格式为{d}{n} 例如：20220101000001
     */
    String value() default "{d}{n}";

    /** 时间类型 数字在此时间内唯一 */
    String dateFormat() default "yyyyMMdd";

    /** 数字长度 */
    int numberLength() default 3;
}
